<?php
if(!defined('INEZCMS')){
	exit('Access Denied');
}
if(empty($userlogininfo)){
    
    jump(SITEURL."/login.html", '您还没有登录!');
}
    // 会员信息
	$do = $_GET['do']?$_GET['do']:'myinfo';
	$ezuser=$ezhand->select("member","*","id=".$userlogininfo["uid"]);
	if ($do == 'myinfo') {
		if ($_POST['sub'] != '') {
			$email = trim($_POST['email']);
			$mobile = trim($_POST['mobile']);
            $company=trim($_POST["company"]);
            $contect=trim($_POST["contect"]);
            $nickname=trim($_POST["nickname"]);
			if (reg_email($email) == 0) {
				jump(-1, 'email格式错误！');
			} 
			//if ($mobile != '' && reg_mobile($mobile) == 0) {
			//	jump(-1, '手机号码格式错误！');
			//} 
            if($email<>$ezuser["email"]){
			if ($ezhand -> check_my_email($email, $ezuser['id']) > 0) {
				jump(-1, 'email已被使用！');
			} 
            }
            if($nickname<>$ezuser["nickname"]){
			if ($ezhand -> check_nickname($nickname, $ezuser['id']) > 0) {
				jump(-1, '昵称已被使用！');
			} 
            }
            //
            $field_arr=array("email"=>$email,"company"=>$company,"mobile"=>$mobile,"contect"=>$contect,"nickname"=>$nickname);

			$ezhand -> update('member', $field_arr, 'id=' . $ezuser['id']);
	        if($nickname<>""){
	           $username=$nickname;
	        }
			user_login($ezuser['id'],$username,$life); //登陆状态
	
			$goto = u('user', 'info');
			jump($goto);
		} 


	} elseif ($do == 'pwd') {
		if ($_POST['sub'] != '') {
			if ($_POST['ezpwd'] != $_POST['pwd_confirm']) { // 两次密码对比
				$re = json_encode(array('s' => 0, 'id' => 34));
				ez_exit($re);
			} 
			if (reg_password($_POST['ezpwd']) == 0) { // 密码格式
				$re = json_encode(array('s' => 0, 'id' => 3));
				ez_exit($re);
			} 
	
			if ($ezhand -> check_oldpass($_POST['old_pwd'], $ezuser['id']) == 'false') {
				$re = json_encode(array('s' => 0, 'id' => 4));
				ez_exit($re);
			} 
	
			if ($webset['ucenter']['open'] == 1) {
				include EZROOT . '/comm/uc_define.php';
				include_once EZROOT . '/uc_client/client.php';
				$uc_name = iconv("utf-8", "utf-8", $username);
				$ucresult = uc_user_edit($ezuser['name'], $_POST['old_pwd'], $_POST['ezpwd']);
				if ($ucresult <= 0) {
					$re = json_encode(array('s' => 0, 'id' => 4));
					ez_exit($re);
				} 
			} 
	
			$field_arr['password'] = md5($_POST['ezpwd']);
			$ezhand -> update('member', $field_arr, 'id=' . $ezuser['id']);
			//user_login($ezuser['id'], $field_arr['ddpassword'], $userlogininfo['ddsavetime']); //重置登陆状态
			//$re = json_encode(array('s' => 1));
			$goto = u('user', 'info',array("do"=>"pwd"));
			jump($goto);            
			ez_exit($re);
		} 
	} 
?>